//
//  BackPassword_TwoViewController.m
//  O2O Product
//
//  Created by 特沃兹 on 2017/12/29.
//  Copyright © 2017年 Product Author. All rights reserved.
//

#import "BackPassword_TwoViewController.h"

@interface BackPassword_TwoViewController ()

@end

@implementation BackPassword_TwoViewController

#pragma mark - ---------- Lazy Loading（懒加载） ----------
-(UILabel *)Label{
    if (_Label == nil) {
        _Label = [[UILabel alloc]init];
        _Label.text = @"请输入111*****1111收到的短信验证吗";
        _Label.textAlignment = NSTextAlignmentLeft;
        _Label.textColor = Color_333333;
    }
    return _Label;
}
-(TextFieldView *)ValidationText
{
    if (_ValidationText == nil) {
        _ValidationText = [[TextFieldView alloc]initWithFrame:CGRectMake(20, 50+TopBarHeight, Main_Screen_Width-100, 50)];
        _ValidationText.backgroundColor = [UIColor clearColor];
        _ValidationText.layer.borderWidth = 1;
        _ValidationText.layer.borderColor = [ChangeColor hexStringToColor:@"d2d2d2"].CGColor;
        [_ValidationText.leftIcon setImage:[UIImage imageNamed:@"Login_Validation"] forState:UIControlStateNormal];
        _ValidationText.placeholderString = @"请输入验证码";
        _ValidationText.maxTextLength = 6;
        _ValidationText.layer.cornerRadius = 2;
        _ValidationText.TextF.keyboardType = UIKeyboardTypePhonePad;
    }
    return _ValidationText;
}
-(UIButton *)SMSButton{
    if (_SMSButton == nil) {
        _SMSButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_SMSButton setBackgroundColor:Color_d73b3c];
        [_SMSButton setTitle:@"重新发送" forState:UIControlStateNormal];
        [_SMSButton.layer setCornerRadius:2];
        [_SMSButton addTarget:self action:@selector(SMSAction) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _SMSButton;
}
-(UIButton *)NextStepButton{
    if (_NextStepButton == nil) {
        _NextStepButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_NextStepButton setBackgroundColor:Color_d73b3c];
        [_NextStepButton setTitle:@"下一步" forState:UIControlStateNormal];
        [_NextStepButton setTitleColor:Color_ffffff forState:UIControlStateNormal];
        [_NextStepButton.layer setCornerRadius:2];
        [_NextStepButton addTarget:self action:@selector(NextStepAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _NextStepButton;
}
-(UIButton *)ContactButton{
    if (_ContactButton == nil) {
        _ContactButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_ContactButton setTitle:@"遇到问题？联系客服" forState:UIControlStateNormal];
        [_ContactButton setTitleColor:Color_999999 forState:UIControlStateNormal];
        [_ContactButton addTarget:self action:@selector(ContactAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _ContactButton;
}
#pragma mark - ----------   Lifecycle（生命周期） ----------
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view setBackgroundColor:[UIColor whiteColor]];

    
    [self InitSubView];

}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}
-(void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}
#pragma mark - ---------- Private Methods（私有方法） ----------

#pragma mark initliaze data(初始化数据)

#pragma mark config control（布局控件）
-(void)InitSubView{
    [self.view addSubview:self.Label];
    [self.Label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_offset(0);
        make.top.mas_offset(TopBarHeight);
        make.size.mas_offset(CGSizeMake(Main_Screen_Width-40, 40));
    }];
    [self.view addSubview:self.SMSButton];
    [self.SMSButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(TopBarHeight+50);
        make.right.mas_offset(-20);
        make.size.mas_offset(CGSizeMake(194/2, 50));
    }];
    [self.view  addSubview:self.ValidationText];
    [self.ValidationText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(TopBarHeight+50);
        make.left.mas_offset(20);
        make.right.equalTo(self.SMSButton.mas_left).offset(-10);
        make.bottom.equalTo(self.SMSButton.mas_bottom).offset(0);
    }];
    [self.view addSubview:self.NextStepButton];
    [self.NextStepButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_offset(0);
        make.top.equalTo(self.SMSButton.mas_bottom).offset(20);
        make.size.mas_offset(CGSizeMake(Main_Screen_Width-40, 50));
    }];
    [self.view addSubview:self.ContactButton];
    [self.ContactButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.NextStepButton.mas_bottom).offset(10);
        make.right.equalTo(self.NextStepButton.mas_right).offset(0);
        make.size.mas_offset(CGSizeMake(180, 40));
    }];
}
#pragma mark networkRequest (网络请求)



#pragma mark IBActions （点击事件xib）
-(void)ReturnViewAction{
    /*返回上一页*/
    [self dismissViewControllerAnimated:YES completion:nil];

}
//短信
-(void)SMSAction{
    /*一进页面自动倒数计时60S（可配置），不可点击。倒数结束后文本变为“重新发送”，可点击*/
    [self dismissViewControllerAnimated:YES completion:nil];

}
//下一步
-(void)NextStepAction{
    /*
     验证码为空时为灰态。点击飘字“请输入验证码”；验证码错误飘字“验证码错误，还有N次机会”，默认3次机会。超过3次则飘字“请重新获取验证码”
     */
    [self presentViewController:[BackPassword_ThreeViewController new] animated:YES completion:nil];
}
//联系客服
-(void)ContactAction{
    /*点击调用手机拨号功能并填充客户号码（后台配置）*/
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
